unit JATUIF_Component_Label;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, JATUIF_Component, JATUIF_Driver_Screen;

Type

    { TLabel }

    TLabel = class(TComponent)
      Protected
        Procedure _OnMouseEnter; override;
        Procedure _OnMouseLeave; override;
        Procedure _OnClick; override;
        Procedure Draw; override;
      Private
        Label_Text:String;
        Label_Text_Color:Byte;
        Label_Background_Color:Byte;
        Label_X,Label_Y:Integer;
        Function GetText:String;
        Procedure SetText(NewText:String);
      Public
        Constructor Create(Parent:TScreen; X,Y:Integer; Text:String; TextColor:Byte; BackgroundColor:Byte);
        Property Text:String read GetText write SetText;
    end;

implementation

{ TLabel }

procedure TLabel._OnMouseEnter;
begin
     inherited _OnMouseEnter;
end;

procedure TLabel._OnMouseLeave;
begin
     inherited _OnMouseLeave;
end;

procedure TLabel._OnClick;
begin
     inherited _OnClick;
end;

procedure TLabel.Draw;
begin
     Screen.DrawXY(GetTag,Label_X,Label_Y,Label_Text,Label_Text_Color,Label_Background_Color);
end;

function TLabel.GetText: String;
begin
     Result:= Label_Text;
end;

procedure TLabel.SetText(NewText: String);
begin
     Label_Text:= NewText;
     Draw;
end;

constructor TLabel.Create(Parent:TScreen; X, Y: Integer; Text: String; TextColor: Byte; BackgroundColor: Byte);
begin
     Label_X:=X;
     Label_Y:=Y;
     Label_Background_Color:= BackgroundColor;
     Label_Text_Color:= TextColor;
     Label_Text:= Text;
     inherited Create(Parent,X,Y,X+Length(Label_Text),Y);
end;

end.

